import format from '@dfeidao/atom-web/dt/format';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';
import p001 from './p001';
import p002 from './p002';

export default async function a001(fd: IFeidaoAiBrowserComponent, d: string) {
	// todo
	// 页面初始化
	const particulars = fd.data.node.querySelector<HTMLDivElement>('[data-id="particulars"]');
	set_node_cls(particulars, 'display-n', false);
	show(fd.data.node);
	const d1 = d;
	// 根据编号（d）查询数据
	const res1 = await nodejs<Array<{  sponsor: string, inform_title: string, inform_content: string, notification_time: number  }>>('notification-notice/zj-000002/s001',
		{
			filter: {
				d: d1
			}
		});
		console.log('res1',res1);
	// 日期格式化
	const newres1 = res1.map((n) => {
		return { ...n, notification_time: format(n.notification_time, 2) };
	});
	render(fd, newres1, p001, 'p001', "inner");
	const res2 = await nodejs<Array<{ annex_file: string, annex_no: string, annex_name: string  }>>('notification-notice/zj-000002/s002',
		{
			filter: {
				d: d1
			}
		});
	if (res2.length < 1) {
		render(fd, "", p002, 'p002', "inner");
	} else {
		render(fd, res2, p002, 'p002', "inner");
	}

}
